/**
 * @param  {String}  url
 * @param  {Boolean} isNoCaseSensitive 是否区分大小写
 * @return {Object}
 */
// import numeral from 'numeral';

import { Base64 } from 'js-base64';
import JSEncrypt from 'jsencrypt';

export const getWidth = () => {
  return { width: window.innerWidth };
};
export const rsaPsw = (password: string) => {
  const pub =
    '-----BEGIN PUBLIC KEY-----MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCpnalpKqFHRLMw5j8bbfqROAG9x5UnkeRB/bdE0J0cN0pJPunXM9+OmTTbxWMyLEHLYiBqnUNIwh7nNrWK3RffiWgIlhhCSGS3aRgUTi/73DCh4ddAJpgPE7/dNfxVb9yqEb5SDIP3NSq+r5CCtz2Kw5SeojgljzY4liiRlWSYzwIDAQAB-----END PUBLIC KEY-----';
  const encryptor = new JSEncrypt();

  encryptor.setPublicKey(pub);

  return encryptor.encrypt(Base64.encode(password));
};

export default {
  getWidth,
  rsaPsw,
};

export const getFileExtension = (filename: string) =>
  filename.slice(filename.lastIndexOf('.') + 1).toLowerCase();
